OpenBuildings GenerativeComponents Help

Examining a Value's List-ness

Every GCScript value has properties and methods, which are like variables and functions, respectively, that are attached to that value. These will be described more thoroughly in a later section. Properties are like variables that are attached  that, among other things, let us examine whether the value is a list, and (if so) its level of nestedness (rank).

value.IsList – This property returns true if value is a list, otherwise false.

value.Rank() – This method returns the rank of the list (or zero if it's not a list). (If you don't remember what a lists' rank is, please review the section, List Values, above.)

Examples

n = 11
n.IsList                   //
This results in 'false'.
n.Rank()                   //
This results in '0'.
n = {11, 100, -2}
n.IsList                   //
This results in 'true'.
n.Rank()                   //
This results in '1'.
n = {{2, 5}, 0, {400, -3}}
n.Rank()                  //
This also results in '1'. (Remember
                                 
// that a list's rank is the deepest
                                 
// level at which every item is a list.)
n = {{2, 5}, {0}, {400, -3}}
n.Rank()                  //
This results in '2'.
{{2, 5}, {0}, {400, -3}}.Rank()   // Note that
we can call methods
                              
   // directly on values! (Although it's
                              
   // usually pointless.)